/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.games.epkb.entityClasses;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author plebani
 */
@Entity
@Table(name = "association_rule")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AssociationRule.findAll", query = "SELECT a FROM AssociationRule a"),
    @NamedQuery(name = "AssociationRule.findById", query = "SELECT a FROM AssociationRule a WHERE a.id = :id"),
    @NamedQuery(name = "AssociationRule.findBySupport", query = "SELECT a FROM AssociationRule a WHERE a.support = :support"),
    @NamedQuery(name = "AssociationRule.findByConfidence", query = "SELECT a FROM AssociationRule a WHERE a.confidence = :confidence"),
    @NamedQuery(name = "AssociationRule.findByDefinitionTime", query = "SELECT a FROM AssociationRule a WHERE a.definitionTime = :definitionTime")})
public class AssociationRule implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    private String id;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "Support")
    private BigDecimal support;
    @Column(name = "Confidence")
    private BigDecimal confidence;
    @Column(name = "DefinitionTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date definitionTime;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "associationRule")
    private Collection<Consequent> consequentCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "associationRule")
    private Collection<Antecedent> antecedentCollection;

    public AssociationRule() {
    }

    public AssociationRule(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public BigDecimal getSupport() {
        return support;
    }

    public void setSupport(BigDecimal support) {
        this.support = support;
    }

    public BigDecimal getConfidence() {
        return confidence;
    }

    public void setConfidence(BigDecimal confidence) {
        this.confidence = confidence;
    }

    public Date getDefinitionTime() {
        return definitionTime;
    }

    public void setDefinitionTime(Date definitionTime) {
        this.definitionTime = definitionTime;
    }

    @XmlTransient
    public Collection<Consequent> getConsequentCollection() {
        return consequentCollection;
    }

    public void setConsequentCollection(Collection<Consequent> consequentCollection) {
        this.consequentCollection = consequentCollection;
    }

    @XmlTransient
    public Collection<Antecedent> getAntecedentCollection() {
        return antecedentCollection;
    }

    public void setAntecedentCollection(Collection<Antecedent> antecedentCollection) {
        this.antecedentCollection = antecedentCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AssociationRule)) {
            return false;
        }
        AssociationRule other = (AssociationRule) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.games.epkb.entityClasses.AssociationRule[ id=" + id + " ]";
    }
    
}
